package hitthetable;
//打表找规律
public class Winner {
    public static void main(String[] args) {
        for (int i = 0; i < 30; i++) {
            System.out.println(i+"  "+winner1(i) + "  "+winner2(i));
        }
    }


    public static String winner1(int n){
        if(n < 5){
            return (n == 0 || n == 2) ? "后手" : "先手";
        }
        int base = 1;
        for(int i = 1; i <= n; i++){

            if(winner1(n - base).equals("后手")){
                return "先手";
            }

            if(base > n / 4){
                break;
            }
            base *= 4;
        }
        return "后手";
    }

    public static String winner2(int n){
        if(n % 5 == 0 || n % 5 == 2 ){
            return "后手";
        }
        return "先手";
    }
}

